package com.emm.yixun.mobile.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.model.ScreenOneModel;

public class ScreenONEAdapter extends BaseAdapter {

	Context context;

	List<ScreenOneModel> list;

	int postions = 0;

	public ScreenONEAdapter(Context context, List<ScreenOneModel> list) {
		this.context = context;
		this.list = list;
	}

	public void SetSelect(int postion) {
		this.postions = postion;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return list == null ? null : list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View a, ViewGroup arg2) {
		ViewHoudler v = null;
		if (a == null) {
			a = LayoutInflater.from(context).inflate(R.layout.sort_screen_item, null);
			v = new ViewHoudler();
			v.textView1 = (TextView) a.findViewById(R.id.textView1_item);
			v.bg_ll = (LinearLayout) a.findViewById(R.id.bg_ll);
			a.setTag(v);
		} else {
			v = (ViewHoudler) a.getTag();
		}
		if (postions != arg0) {
			v.bg_ll.setBackgroundColor(Color.parseColor("#F5F5F5"));
			v.textView1.setTextColor(Color.parseColor("#494949"));
		} else {
			v.bg_ll.setBackgroundColor(Color.parseColor("#ffffff"));
			v.textView1.setTextColor(Color.parseColor("#f87242"));
		}
		v.textView1.setText(list.get(arg0).getName1());
		return a;
	}

	public static class ViewHoudler {
		TextView textView1;
		LinearLayout bg_ll;
	}

}
